$(document).ready(function () {
    // 点击发送验证码开始
    var onOff = 0;//控制发送验证码开关
    $('.verification').on('click',function () {
        if(onOff==0){
            $.ajax({
                "url": "/sendValidateCode",
                "type": "POST",
                data: {
                    "bizType": "USER_INFO_MODIFY"
                },
                success: function (result) {
                    if (result.code == 1) {
                        //按钮30s秒倒计时
                        var time = 30;
                        var Inter = setInterval(function () {
                            if (time >= 1) {
                                time--;
                                $(".verification").html(time + "s后重新发送");
                                onOff=1;
                            } else {
                                clearInterval(Inter);
                                $(".verification").html("重新发送");
                                onOff=0;
                            }
                        }, 1000);


                    } else {
                        $.toast(result.message);
                    }
                }
            });
        }
    });
    // 点击发送验证码结束


    // 点击保存开始
    $(".preservation").on("click",function () {
        // 获取银行卡信息
        var id = $('.formId').val();
        var oemId = $('.oemId').val();
        var accountName = $('.accountName').val();
        var cardNo = $('.cardNo').val();
        var bankCode = $('.bankCode').val();
        var provice = $('.provice').val();
        var city = $('.city').val();
        var validateCode = $('.validateCode').val();
        var params = {id:id,oemId:oemId,accountName:accountName,cardNo:cardNo,bankCode:bankCode,provice:provice,city:city,validateCode:validateCode};
        // 判断信息是否为空
        if(accountName == ''){
            $.toast("开户名不能为空");
        }else if (/^[1-9]\d*$|^0$/.test(cardNo)!= true){
            $.toast("银行卡号有误");
        }else if (bankCode==''){
            $.toast("银行名称不能为空");
        }else if (provice == ''){
            $.toast("开户省份不能为空");
        }if (city == ''){
            $.toast("开户市不能为空");
        }else if(validateCode==''){
            $.toast("验证码不能为空");
        }else {
            $.post('/bankcard/edit',params,function (result) {
                if(result.code==1){
                    $.toast("保存成功");
                    $('.validateCode').val('');
                }else{
                    $.toast(result.message);
                    $('.validateCode').val('');
                }
            });
        }
    })
    // 点击保存结束
});